mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-15 14:38:03 +02:00
fix: regex characters in terms shouldn't block submission
Entering an IP address (e.g. 192.168.1.1) or any term with regex
metacharacters made the form invalid because the "regex characters
detected" hint was wired up via $setValidity('terms', 'regex', false).
The text in the UI labels it as a warning, but the form treated it as
an error and refused to save.
Track the warning as a plain $scope flag and show it via ng-show on
that flag, so the form stays valid (#430).
This commit is contained in:
@@ -149,7 +149,7 @@
|
||||
<label class="paper-field-label" for="terms">Terms to redact</label>
|
||||
<textarea class="form-control" id="terms" name="terms" rows="4" ng-model="terms" ng-model-options="{ debounce: 250 }" ng-class="{'is-invalid': anonymize.terms.$invalid}"></textarea>
|
||||
<small class="form-text text-muted">One term per line (regex allowed). Replaced by <code>{{site_options.ANONYMIZATION_MASK}}-[N]</code>, or use <code>term=>replacement</code> to pick your own (e.g. <code>Anonymous=>ABC</code>).</small>
|
||||
<div class="warning-feedback" ng-show="anonymize.terms.$error.regex">Regex characters detected. Escape them if unintentional.</div>
|
||||
<div class="warning-feedback" ng-show="termsRegexWarning">Regex characters detected. Escape them if unintentional.</div>
|
||||
<div class="invalid-feedback" ng-show="anonymize.terms.$error.format">Terms are in an invalid format.</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1375,10 +1375,11 @@ angular
|
||||
|
||||
function anonymizeReadme() {
|
||||
if (!$scope.anonymize || !$scope.anonymize.terms) return;
|
||||
setValidity("terms", "regex", true);
|
||||
if ($scope.terms && $scope.terms.match(/[-[\]{}()*+?.,\\^$|#]/g)) {
|
||||
setValidity("terms", "regex", false);
|
||||
}
|
||||
// The "regex characters detected" hint is informational, not a blocker
|
||||
// — IP addresses, escaped chars, etc. are all legitimate terms (#430).
|
||||
// Track it as a plain $scope flag so it doesn't mark the form invalid.
|
||||
$scope.termsRegexWarning =
|
||||
!!$scope.terms && !!$scope.terms.match(/[-[\]{}()*+?.,\\^$|#]/g);
|
||||
const urlRegex = /<?\b((https?|ftp|file):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]\b\/?>?/g;
|
||||
let content = $scope.readme;
|
||||
if (!$scope.options.image) {
|
||||
@@ -1486,7 +1487,7 @@ angular
|
||||
setValidity("sourceUrl", "github", true);
|
||||
setValidity("conference", "activated", true);
|
||||
setValidity("terms", "format", true);
|
||||
setValidity("terms", "regex", true);
|
||||
$scope.termsRegexWarning = false;
|
||||
}
|
||||
|
||||
function displayErrorMessage(message) {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user